<?php

!defined('IN_APP') && exit('Access Denied');

class areamodel {

    var $db;
    var $base;

    function __construct(&$base) {
        $this->base = $base;
        $this->db = $base->db;
    }

    function get($uid) {
        $user = $this->db->fetch_first("SELECT * FROM " . DB_TABLEPRE . "user WHERE uid='$uid'");
        return $user;
    }

    function get_by_pid($pid) {
        $arealist = array();
        $query = $this->db->query("SELECT * FROM " . DB_TABLEPRE . "area WHERE pid=$pid ");
        while ($area = $this->db->fetch_array($query)) {
            $arealist[] = $area;
        }
        return $arealist;
    }

    function get_area_select($pid) {
        $arealist = $this->get_by_pid($pid);
        $areaoption = '';
        foreach ($arealist as $area) {
            $areaoption .= '<option value="' . $area['id'] . '">' . $area['name'] . '</option>';
        }
        return $areaoption;
    }

}

?>